<?php PageUtil::addVar("stylesheet","<link href=\"".$stylepath."/forum.css\" rel=\"stylesheet\">");?>
<?php PageUtil::addVar("stylesheet","<link href=\"".$stylepath."/post.css\" rel=\"stylesheet\">");?>

<div class="content_block col-xs-12">
  <section class="row">
    <section class="post_title col-xs-12 col-sm-12 col-md-12 col-lg-12">
      <a href="<?php echo base_url("forum/category/".$forum[0]['url']);?>">
        <h1>
          <img src="<?php echo $imagepath;?>/topic_icon.png"> <?php echo $forum[0]["name"];?>
        </h1>
        <a class="btn btn-success pull-right" href="<?php echo base_url("forum/create/".$forum[0]["id"]); ?>"><i class="icon-pencil"></i> สร้างกระทู้ใหม่</a>
      </a>
    </section>
  </section>

  <table class="table table-hover table-condensed">
    <thead>
      <tr>
        <th width="10%"></th>
        <th width="70%"></th>
        <th width="20%"></th>
      </tr>
    </thead>
    <tbody>
    <?php
      if(!empty($listpost)){
        foreach ($listpost as $key => $value) {
    ?>
      <tr>
        <td class="post-list-image">
          <?php
            if(!empty($value["images"])){
            ?>
              <img src="<?php echo base_url($value["images"][0]["small"]);?>" width="60">
            <?php
            }else{
              ?>
              <img src="<?php echo $imagepath."/not_available.jpg";?>" width="60">
              <?php
            }
          ?>
        </td>
        <td>
          <div class="post-list">
            <a href="<?php echo base_url('forum/view/'.$value["url"]);?>"><strong><?php echo $value["title"];?></strong></a>
            <div class="muted"><small><?php echo mb_substr(strip_tags($value["content"]), 0, 60,"UTF-8");?>...</small></div>
          </div>
        </td>
        <td class="category-list-detail">
          โดย <?php echo $value["user"]["first_name"];?><br />
          เมื่อ <?php echo Util::ezDate($value['cr_date']); ?>
        </td>
      </tr>
    <?php
        }
      }else{
        ?>
      <tr>
        <td colspan="3">
          <div class="alert alert-danger">
            <p class="text-center">ยังไม่มีหมวดหมู่ย่อย</p>
          </div>
        </td>
      </tr>
    <?php
      }
    ?>
    </tbody>
  </table>
  <div class="pagination text-center"><ul><?php echo $this->pagination->create_links();?></ul></div>
</div>